home *** CD-ROM | disk | FTP | other *** search
/ Word Play Farm / Word Play Farm.iso / pc / movies / shared.dxr / 00514_Utility Handlers.ls < prev    next >
Encoding:
Text File  |  1996-07-29  |  4.1 KB  |  192 lines

  1. on LoseExt textstr
  2.   set dot to offset(".", textstr)
  3.   if dot > 1 then
  4.     set textstr to chars(textstr, 1, dot - 1)
  5.   end if
  6.   return textstr
  7. end
  8.  
  9. on HandleKey psKey, psInputString
  10.   if voidp(psInputString) then
  11.     set psInputString to EMPTY
  12.   end if
  13.   if psKey = BACKSPACE then
  14.     delete char length(psInputString) of psInputString
  15.   else
  16.     set psKey to UpCase(psKey)
  17.     set liAsciiCh to charToNum(psKey)
  18.     if (liAsciiCh >= 65) and (liAsciiCh <= 90) then
  19.       put psKey after psInputString
  20.     end if
  21.   end if
  22.   return psInputString
  23. end
  24.  
  25. on TypeWord psActiveWord, piStart, piLen
  26.   if voidp(piLen) then
  27.     set piLen to length(psActiveWord)
  28.   end if
  29.   set liWordSize to length(psActiveWord)
  30.   repeat with liCnt = 1 to piLen
  31.     set liSpriteNum to liCnt + piStart - 1
  32.     if liCnt <= liWordSize then
  33.       set lsChar to char liCnt of psActiveWord
  34.       set liCastNum to the number of cast lsChar
  35.       if the castNum of sprite liSpriteNum <> liCastNum then
  36.         puppetSprite(liSpriteNum, 0)
  37.         puppetSprite(liSpriteNum, 1)
  38.         set the castNum of sprite liSpriteNum to liCastNum
  39.         updateStage()
  40.       end if
  41.       next repeat
  42.     end if
  43.     puppetSprite(liSpriteNum, 0)
  44.   end repeat
  45. end
  46.  
  47. on UpCase psChar
  48.   set liAsciiCh to charToNum(psChar)
  49.   if (liAsciiCh >= 97) and (liAsciiCh <= 122) then
  50.     set liAsciiCh to liAsciiCh - 32
  51.   end if
  52.   if (liAsciiCh >= 32) and (liAsciiCh <= 125) then
  53.     return numToChar(liAsciiCh)
  54.   else
  55.     return EMPTY
  56.   end if
  57. end
  58.  
  59. on SwapSprite pSpriteNum, pCastName
  60.   if the number of cast pCastName = -1 then
  61.     exit
  62.   end if
  63.   set pSpriteNum to value(pSpriteNum)
  64.   set lPuppetState to the puppet of sprite pSpriteNum
  65.   if lPuppetState = 0 then
  66.     puppetSprite(pSpriteNum, 1)
  67.   end if
  68.   set lCastNumber to the number of cast pCastName
  69.   set the castNum of sprite pSpriteNum to lCastNumber
  70. end
  71.  
  72. on killSprites low, high
  73.   if the paramCount = 0 then
  74.     set low to 1
  75.     set high to 48
  76.   end if
  77.   repeat with t = low to high
  78.     puppetSprite(t, 0)
  79.   end repeat
  80. end
  81.  
  82. on SSelect pOffSet
  83.   return the clickOn - pOffSet + 1
  84. end
  85.  
  86. on makefilename textstr, extstr
  87.   if voidp(extstr) then
  88.     set lRetName to chars(textstr, 1, 8)
  89.   else
  90.     set lRetName to chars(textstr, 1, 8) & "." & chars(extstr, 1, 3)
  91.   end if
  92.   return lRetName
  93. end
  94.  
  95. on MakeList prefix, suffix, Num
  96.   set FileList to makefilename(prefix & "1", suffix)
  97.   repeat with i = 2 to Num
  98.     set textstr to prefix & string(i)
  99.     set fileName to makefilename(textstr, suffix)
  100.     put the itemDelimiter & fileName after FileList
  101.   end repeat
  102.   return FileList
  103. end
  104.  
  105. on MakeItemList pNum, pValue
  106.   if voidp(pValue) then
  107.     set pValue to 0
  108.   end if
  109.   set lRetStr to pValue
  110.   repeat with i = 2 to pNum
  111.     put "," & pValue after lRetStr
  112.   end repeat
  113.   return lRetStr
  114. end
  115.  
  116. on holdSound schannel
  117.   if voidp(schannel) then
  118.     set schannel to 1
  119.   end if
  120.   repeat while soundBusy(schannel)
  121.     nothing()
  122.   end repeat
  123. end
  124.  
  125. on repeat4Sound pFrame, schannel
  126.   if voidp(pFrame) then
  127.     set pFrame to 0
  128.   end if
  129.   if voidp(schannel) then
  130.     set schannel to 1
  131.   end if
  132.   if soundBusy(schannel) then
  133.     go(the frame - pFrame)
  134.   end if
  135. end
  136.  
  137. on RandomSound NameList
  138.   global gLastRandomPlay
  139.   set itemcnt to the number of items in NameList
  140.   set itemnum to random(itemcnt)
  141.   repeat while itemnum = gLastRandomPlay
  142.     set itemnum to random(itemcnt)
  143.   end repeat
  144.   set gLastRandomPlay to itemnum
  145.   set soundname to item itemnum of NameList
  146.   PlayAudio(soundname)
  147.   repeat4Sound()
  148. end
  149.  
  150. on mousesound
  151.   global MSound
  152.   PlayAudio(MSound)
  153.   holdSound()
  154.   puppetSound(0)
  155. end
  156.  
  157. on PlayAudio psAudio
  158.   sound stop 1
  159.   puppetSound(0)
  160.   if not voidp(psAudio) then
  161.     if the number of cast psAudio <> -1 then
  162.       puppetSound(psAudio)
  163.       updateStage()
  164.     else
  165.       sound playFile 1, psAudio
  166.     end if
  167.   else
  168.     beep(1)
  169.   end if
  170. end
  171.  
  172. on MoviePlay pMovieName, pLabelName
  173.   global gJumpFrame, gJumpName
  174.   if pMovieName <> 1 then
  175.     set gJumpFrame to the frame
  176.     set gJumpName to the movieName
  177.     if voidp(pLabelName) then
  178.       set pLabelName to 1
  179.     end if
  180.     go(pLabelName, pMovieName)
  181.   else
  182.     go(gJumpFrame, gJumpName)
  183.   end if
  184. end
  185.  
  186. on WaitaSec piTime
  187.   startTimer()
  188.   repeat while the timer < (60 * piTime)
  189.     nothing()
  190.   end repeat
  191. end
  192.